1 package com.flexiblewebsolutions.xdriveunit;
2
3 import java.util.ArrayList;
4 import java.util.Iterator;
5
6 import junit.framework.Test;
7 import junit.framework.TestSuite;
8
9 /***
10 * Organizes tests to avoid issue of multiple nested test suites
11 *
12 * @author Donavon Buss
13 */
14 class TestCollection {
15 private ArrayList _Tests = new ArrayList();
16
17 /***
18 * Store a test until it is needed
19 *
20 * @param pTest -
21 * Either a TestSuite or single test case
22 */
23 public void addTest(Test pTest) {
24 _Tests.add(pTest);
25 }
26
27 /***
28 * Returns a test suite if multiple tests in storage, or a single test if
29 * only one.
30 *
31 * @return Test
32 */
33 public Test getTest() {
34 if (_Tests.size() == 1) {
35 return ((Test) _Tests.get(0));
36 } else {
37 TestSuite ts = new TestSuite();
38 for (Iterator it = _Tests.iterator(); it.hasNext();) {
39 Test thisTest = (Test) it.next();
40 ts.addTest(thisTest);
41 }
42 return (ts);
43 }
44 }
45 }